package com.deyuanyun.pic.settings.controller.dto.prvlg;

import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.settings.domain.prvlg.Menu;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by linwei on 2016/1/28.
 */
public class MenuVO {

    private String id;

    public int rowNo;

    private Date createDate;

    private String createUser;

    private String createRemark;

    private String parentId;

    private String code;

    private String name;

    private String showName;

    private Short type;

    private String url;

    private String imgUrl;

    private Short sort;

    private Short state;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? StringUtils.LINE : id.trim();
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser == null ? StringUtils.LINE : createUser.trim();
    }

    public String getCreateRemark() {
        return createRemark;
    }

    public void setCreateRemark(String createRemark) {
        this.createRemark = createRemark == null ? null : createRemark.trim();
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId == null ? StringUtils.LINE : parentId.trim();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code == null ? StringUtils.LINE : code.trim();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? StringUtils.LINE : name.trim();
    }

    public String getShowName() {
        return showName;
    }

    public void setShowName(String showName) {
        this.showName = showName == null ? StringUtils.LINE : showName.trim();
    }

    public Short getType() {
        return type;
    }

    public void setType(Short type) {
        this.type = type;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url == null ? StringUtils.LINE : url.trim();
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl == null ? StringUtils.LINE : imgUrl.trim();
    }

    public Short getSort() {
        return sort;
    }

    public void setSort(Short sort) {
        this.sort = sort;
    }

    public Short getState() {
        return state;
    }

    public void setState(Short state) {
        this.state = state;
    }

    public int getRowNo() {
        return rowNo;
    }

    public void setRowNo(int rowNo) {
        this.rowNo = rowNo;
    }

    public MenuVO toDomain(Menu menu){
        MenuVO menuVO = new MenuVO();
        menuVO.setCode(menu.getCode());
        menuVO.setCreateDate(menu.getCreateDate());
        menuVO.setCreateRemark(menu.getCreateRemark());
        menuVO.setCreateUser(menu.getCreateUser());
        menuVO.setId(menu.getId());
        menuVO.setImgUrl(menu.getImgUrl());
        menuVO.setName(menu.getName());
        menuVO.setShowName(menu.getShowName());
        menuVO.setParentId(menu.getParentId());
        menuVO.setSort(menu.getSort());
        menuVO.setState(menu.getState());
        menuVO.setType(menu.getType());
        menuVO.setUrl(menu.getUrl());
        return menuVO;
    }

    public List<MenuVO> toDomain(List<Menu> list){
        List<MenuVO> listMenuVO = new ArrayList<MenuVO>();
        int i = 1;
        for (Menu menu : list){
            MenuVO menuVO = this.toDomain(menu);
            menuVO.setRowNo(i);
            listMenuVO.add(menuVO);
            i++;
        }
        return listMenuVO;
    }
}
